package com.wuxb.pool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class UseThreadPoolExecutor {

    public static void main(String[] args) {

        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1, 2, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(3));

        MyTask myTask1 = new MyTask(1);
        MyTask myTask2 = new MyTask(2);
        MyTask myTask3 = new MyTask(3);
        MyTask myTask4 = new MyTask(4);
        MyTask myTask5 = new MyTask(5);
        MyTask myTask6 = new MyTask(6);
        MyTask myTask7 = new MyTask(7);

        poolExecutor.execute(myTask1);
        poolExecutor.execute(myTask2);
        poolExecutor.execute(myTask3);
        poolExecutor.execute(myTask4);
        poolExecutor.execute(myTask5);

        poolExecutor.shutdown();
    }
}
